import React from 'react';
import { connect } from 'react-redux';
import { changeCourseField } from '../store/actions/courseTabList';

import CourseField from '../components/CourseField';
import CourseList from '../components/CourseList';


class IndexPage extends React.Component{

  render() {
    const { curField, changeCourseField } = this.props;
    // console.log(curField);
    //-1

    return (
      <div className="page-wrapper">
        <CourseField
          curField={curField}
          changeCourseField={changeCourseField}
        ></CourseField>
        <CourseList
          curField={curField}
        ></CourseList>
      </div>
    )
  }
}

export default connect(
  //提供中央state
  function mapStateToProps(state) {
    return {
      curField: state.courseTabList.curField
    }
  },
  //提供中央state方法
  function mapDispatchToProps(dispatch) {
    return {
      changeCourseField: (field) => dispatch(changeCourseField(field))
    }
  }
)(IndexPage);